package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.FriendshipComment;
import cn.wolfcode.trip.base.domain.FriendshipReply;
import cn.wolfcode.trip.base.service.IFriendshipCommentService;
import cn.wolfcode.trip.base.service.IFriendshipReplyService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/friendshipComments")
public class FriendshipCommentController  {

    @Autowired
    private IFriendshipReplyService replyService;


    /**lituan
     * 保存二级评论
     * @param reply
     * @return
     */
    @PostMapping("/{friendshipcomment.id}/friendshipReplys")
    public JSONResult saveReply (FriendshipReply reply){
        JSONResult jsonResult = new JSONResult() ;

        try {
            FriendshipReply reply1 = replyService.saveReply(reply);
            jsonResult.setReply(reply);
        } catch (Exception e) {
            jsonResult.mark("保存失败,稍后再试");
            e.printStackTrace();
        }

        return jsonResult;
    }

}
